package com.zds.hj.poseidon.biz.dispatcher.credit.wycHandler;

import com.zds.boot.dispatch.annotation.DispatcherHandler;
import com.zds.boot.dispatch.comm.enums.InstructTypeEnum;
import com.zds.boot.dispatch.comm.enums.ModuleNodeTypeEnum;
import com.zds.boot.dispatch.dto.BaseReqModel;
import com.zds.boot.dispatch.dto.BaseResultModel;
import com.zds.boot.dispatch.dto.InstructDto;
import com.zds.boot.dispatch.dto.InstructRegisterModule;
import com.zds.hj.poseidon.facade.dto.hpp.credit.CreditInfoEntityDto;
import com.zds.hj.product.facade.constant.ApplicationContainerConstant;
import com.zds.zly.common.utils.EmptyChecker;
import lombok.extern.slf4j.Slf4j;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author wyc
 * @site www.yiyang.com
 * @company 王云川有限公司
 * @create 2023-06-07 13:46
 */
@DispatcherHandler(value = "CreditProductIntroduceOneHandler", desc = "产品介绍页模块", applicationContainer = ApplicationContainerConstant.FRONT_END, nodeType = ModuleNodeTypeEnum.BUSINESS)
@Slf4j
public class CreditProductIntroduceOneHandler extends WycMainHandler {
    private static final String IMG_CODE ="872786489663563";
//            CreditDemoHandler.class.getName() + ".IMG_CODE";


    @Override
    public void creditDoExecute(BaseReqModel params, BaseResultModel resultModel, CreditInfoEntityDto reqData, CreditInfoEntityDto dbData) {


    }


//    @Override
//    public Object paramsFerry(Object o) {
//        CapitalInfoDto dbDto = (CapitalInfoDto) o;
//        CapitalInfoDto capitalInfoDto = new CapitalInfoDto();
//        capitalInfoDto.setProductNo(dbDto.getProductNo());
//        return capitalInfoDto;
//    }

    @Override
    public BaseResultModel echoDetail(BaseReqModel params) {
        InstructDto instructDto = params.getDispatchModuleNodes().getInstructSettingMap().get(IMG_CODE);
        Map<String, Object> result = new HashMap<>();
        BaseResultModel resultModel = super.defaultResult(params);
        if (EmptyChecker.notEmpty(instructDto)) {
            result.put("imgId", instructDto.getValues());
        } else {
            throw new RuntimeException("介绍页图片加载失败");
        }
        resultModel.setResult(result);
//        CreditInfoEntityDto dbData = creditApplyService.findCreditOnTransit(params);
//        creditApplyService.update(params, dbData);
        return resultModel;
    }

    /**
     * 模块指令
     * @return
     */
    @Override
    public List<InstructRegisterModule> moduleInstructs() {
        List<InstructRegisterModule> instructRegisterModules = new ArrayList<>();
        InstructRegisterModule registerModule2 = new InstructRegisterModule();
        registerModule2.setInstructCode(IMG_CODE);
        registerModule2.setInstructName("产品介绍图片");
        registerModule2.setInstructTitle("产品介绍图片");
        registerModule2.setInstructType(InstructTypeEnum.UPLOAD);
        registerModule2.setInstructEmphatic("产品介绍图片");
        registerModule2.setEmptyCheck(true);
        instructRegisterModules.add(registerModule2);
        return instructRegisterModules;
    }


}
